/*
 *  $Id: UseCard.cs 1241 2011-03-23 13:30:19Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2010 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using Nereal.Extensions;
using Nereal.Serialization;

namespace Ragima.Events {
    /// <summary>
    /// Событие использования карты. Содержит параметры цели и карту.
    /// </summary>
    [TypeId("usecard"), ConstructorParameters("_cardNumber", "Args")]
    public class UseCard : TargetEvent {
        [Serialize, XmlName("card"), DefaultValue(-1)]
        private int _cardNumber;

        public UseCard(HandCard card, TargetArgs args) : this(args.Player.Hands.IndexOf(card), args) {
        }
        public UseCard(int cardNumber, TargetArgs args) : base(args) {
            _cardNumber = cardNumber;
        }

        protected override void ExecuteInner(Game scene) {
            if (Args == null)
                return;
            var card = Args.Player.Hands.GetOrDefault(_cardNumber);
            if (card != null)
                Args.Player.DoUse(card, Args);
            System.Console.WriteLine("Args: player={0}, caster={1}, card={2}", Args.Player.Name, Args.Caster.Name, card.Card.Name);
        }
    }
}
